package com.fileServer.fileHandler;

import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
import org.springframework.web.servlet.resource.PathResourceResolver;

import java.io.File;
import java.io.IOException;


/**
 * @author 大忽悠
 * @create 2023/2/28 10:59
 */
public class CustomPathResourceResolver extends PathResourceResolver {
    @Override
    protected Resource getResource(String resourcePath, Resource location) throws IOException {
        Resource resource = new FileSystemResource(location.getFile().getAbsolutePath()+ File.separator+resourcePath);
        if (resource.isReadable()) {
            return resource;
        }
        return null;
    }
}
